//
//  SALoginViewController.m
//  SunOn
//
//  Created by mc on 2017/5/2.
//  Copyright © 2017年 NeoZhang. All rights reserved.
//  登录界面

#import "SALoginViewController.h"
#import "SABaseViewController.h"
#import "SARegistFirstStepViewController.h"//第一步注册
#import "SAForgetPSWFirstStepViewController.h"//忘记密码第一步

@interface SALoginViewController ()
//账号
@property (weak, nonatomic) IBOutlet UITextField *username;
//密码
@property (weak, nonatomic) IBOutlet UITextField *password;
//记住密码
@property (weak, nonatomic) IBOutlet UIButton *remeberPSW;
//记住密码img //denglu-gou-1
@property (weak, nonatomic) IBOutlet UIImageView *remberImage;

//登录按钮
@property (weak, nonatomic) IBOutlet UIButton *login;
//注册按钮
@property (weak, nonatomic) IBOutlet UIButton *regist;
//忘记密码
@property (weak, nonatomic) IBOutlet UIButton *fogetPSW;


//没有账号?左边距
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *registLeftLayout;//116 iphone 7
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *usernameLayout;// 252 iphone 7

@end

@implementation SALoginViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    //设置view视图中控件属性
    [self configureViewLayout];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

#pragma mark - view cycle
- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
    [[UIApplication sharedApplication] setStatusBarStyle:(UIStatusBarStyleDefault)];
}
- (void)viewWillDisappear:(BOOL)animated {
    [super viewWillDisappear:animated];
    [[UIApplication sharedApplication] setStatusBarStyle:(UIStatusBarStyleLightContent)];
}

- (UIStatusBarStyle)preferredStatusBarStyle {
    return UIStatusBarStyleLightContent;
}
#pragma mark - view action
//记住密码
- (IBAction)remeberPSWAction:(UIButton *)sender {
    NSData *currentdata = UIImagePNGRepresentation(self.remberImage.image);
    NSData *data = UIImagePNGRepresentation(SAImageNamed(@"denglu-gou-1"));//未选中图片
    if ([currentdata isEqual:data]) {
        self.remberImage.image = SAImageNamed(@"denglu-gou");
    }else {
        self.remberImage.image = SAImageNamed(@"denglu-gou-1");
    }
}
//登录
- (IBAction)loginAction:(UIButton *)sender {
    UIApplication *app = [UIApplication sharedApplication];
    SABaseViewController *baseVC = [[SABaseViewController alloc] init];
    app.delegate.window.rootViewController = baseVC;
}
//忘记密码
- (IBAction)forgetPSWAction:(UIButton *)sender {
    SAForgetPSWFirstStepViewController *fistForget = [self.storyboard instantiateViewControllerWithIdentifier:@"SAForgetPSWFirstStepViewController"];
    [self presentViewController:fistForget animated:YES completion:nil];
}
//注册
- (IBAction)registAction:(UIButton *)sender {
    SARegistFirstStepViewController *fistRegist = [self.storyboard instantiateViewControllerWithIdentifier:@"SARegistFirstStepViewController"];
    [self presentViewController:fistRegist animated:YES completion:nil];
}


#pragma mark - view layout
- (void)configureViewLayout {
    SAViewBorderRadius(self.username, 20, 1.0,[UIColor colorWithHexString:@"#59424E"]);
    SAViewBorderRadius(self.password, 20, 1.0,[UIColor colorWithHexString:@"#59424E"]);
    SAViewRadius(self.login, 15);
    self.registLeftLayout.constant = 116 * SAkWidth_scale;
    self.usernameLayout.constant = 252 * SAkHeight_scale;
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
